home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / LEnhancedCicnButton / LEnhancedCicnButton.cp next >
Encoding:
Text File  |  1996-09-14  |  4.5 KB  |  133 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    File:                    LEnhancedCicnButton.cp
  3. // Version:                1.0 - Feb 08,1996
  4. //    Author:                Mike Shields (mshields@inconnect.com)
  5. //
  6. //    Copyright ©1996 Mike Shields. All rights reserved.
  7. //    I hereby grant users of LEnhancedCicnButton permission to use it (or any modified 
  8. //    version of it) in applications (or any other type of Macintosh software 
  9. //    like extensions -- freeware, shareware, commercial, or other) for free, 
  10. //    subject to the terms that:
  11. //
  12. //        (1)  This agreement is non-exclusive.
  13. //
  14. //        (2)  I, Mike Shields, retain the copyright to the original source code.
  15. //
  16. //    These two items are the only required conditions for use. However, I do have 
  17. //    an additional request. Note, however, that this is only a request, and 
  18. //    that it is not a required condition for use of this code.
  19. //
  20. //        (1) That I be given credit for LEnhancedCicnButton code in the copyrights or 
  21. //            acknowledgements section of your manual or other appropriate documentation.
  22. //
  23. //
  24. //    I would like to repeat that this last item is only a request. You are prefectly 
  25. //    free to choose not to do any or all of them.
  26. //    
  27. //        This source code is distributed in the hope that it will be useful,
  28. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30. // ===========================================================================
  31. //    LEnhancedIconPane.cp            <- double-click + Command-D to see class definition
  32. //
  33. //
  34. // LEnhancedCicnButton is an enhancement to the PP supplied LCicnButton Class.
  35. // This subclass will cause the button to appear disabled when the button is 
  36. // actually disabled using Disable(). The normal LCicnButton does not take the 
  37. // Enabled status into account when it is drawing the graphic.
  38. //
  39. #include "LEnhancedCicnButton.h"
  40. #include <LStream.h>
  41.  
  42.  
  43. // ---------------------------------------------------------------------------
  44. //        • CreateFromStream
  45. // ---------------------------------------------------------------------------
  46. //    Create a new CicnButton object from the data in a Stream
  47. LEnhancedCicnButton* LEnhancedCicnButton::CreateFromStream(LStream    *inStream)
  48. {
  49.     return (new LEnhancedCicnButton(inStream));
  50. }
  51.  
  52.  
  53. // ---------------------------------------------------------------------------
  54. //        • LEnhancedCicnButton
  55. // ---------------------------------------------------------------------------
  56. //    Default Constructor
  57. LEnhancedCicnButton::LEnhancedCicnButton()
  58. {
  59. }
  60.  
  61.  
  62. // ---------------------------------------------------------------------------
  63. //        • LEnhancedCicnButton(const LEnhancedCicnButton&)
  64. // ---------------------------------------------------------------------------
  65. //    Copy Constructor
  66. LEnhancedCicnButton::LEnhancedCicnButton(const LEnhancedCicnButton    &inOriginal)
  67.         : LCicnButton(inOriginal)
  68. {
  69. }
  70.  
  71.  
  72. // ---------------------------------------------------------------------------
  73. //        • LEnhancedCicnButton
  74. // ---------------------------------------------------------------------------
  75. //    Construct from input parameters
  76. LEnhancedCicnButton::LEnhancedCicnButton(const SPaneInfo &inPaneInfo, MessageT inClickedMessage,
  77.                                                         ResIDT inNormalID, ResIDT inPushedID)
  78.         : LCicnButton(inPaneInfo, inClickedMessage, inNormalID, inPushedID)
  79. {
  80. }
  81.  
  82.  
  83. // ---------------------------------------------------------------------------
  84. //        • LEnhancedCicnButton(LStream*)
  85. // ---------------------------------------------------------------------------
  86. //    Construct a new CicnButton from the data in a Stream
  87. //
  88. //    Stream data must be:
  89. //        ResIDT        Resource ID for normal graphic
  90. //        ResIDT        Resource ID for pushed graphic
  91. LEnhancedCicnButton::LEnhancedCicnButton(LStream *inStream)
  92.         : LCicnButton(inStream)
  93. {
  94. }
  95.  
  96.  
  97. // ---------------------------------------------------------------------------
  98. //        • ~LEnhancedCicnButton
  99. // ---------------------------------------------------------------------------
  100. //    Destructor
  101. LEnhancedCicnButton::~LEnhancedCicnButton()
  102. {
  103. }
  104.  
  105.  
  106. // ---------------------------------------------------------------------------
  107. //        • DrawSelf
  108. // ---------------------------------------------------------------------------
  109. //    Draw the CicnButton
  110. void LEnhancedCicnButton::DrawSelf()
  111. {
  112.     Rect    frame;
  113.     CalcLocalFrameRect(frame);
  114.     
  115.     if ( mNormalCicnH == nil ) 
  116.     {        // Load 'cicn' if necessary
  117.         mNormalCicnH = ::GetCIcon(mNormalID);
  118.     }
  119.     
  120.     if ( mNormalCicnH != nil ) 
  121.     {
  122.         if ( mEnabled != triState_Off ) 
  123.         {
  124.             ::PlotCIconHandle(&frame, atNone, ttNone, mNormalCicnH);
  125.         } 
  126.         else 
  127.         {
  128.             ::PlotCIconHandle(&frame, atNone, ttDisabled, mNormalCicnH);
  129.         }
  130.     }
  131. }
  132.  
  133.